
REM #!/bin/sh

npm install
git submodule update --init --recursive
rmdir /S /Q plugins
rmdir /S /Q platforms
set env="dev"
set appId="00015fddefbc75de"
REM set tokeAPIServer="http://120.78.81.170/api/micropaas-auth-peiping/oauth/token"

if /I [%3] == [test] (
	set env="test"
	set appId="0001622da8f1c353bb"
	REM set tokeAPIServer="https://weixin.wuyixi.com/api/micropaas-auth-peiping/oauth/token"
) else ( 
    if /I [%3] == [prod] (
        set env="prod"
        set appId="0001622da8f1c353bb"
        REM set tokeAPIServer="https://app.csg.cn:9093/api/micropaas-auth-peiping/oauth/token"
    )
)

echo "%env%---------%appId%-------%tokeAPIServer%"

REM ionic cordova plugin add myplugins/cordova-plugin-inappbroswerwithheader
REM ionic cordova plugin add myplugins/cordova-plugin-enterprisewechat --variable WWECHATAPPID=%appId% --variable GETCODEAPI=%tokeAPIServer% --variable EWC_SCOPE="e23j3442jp2" --variable EWC_STATE="1d9919f3w7d" --variable SCHEMES="csgWuye"


if /I [%1] == [ios] ( 
	ionic cordova platform add ios
	if /I [%2] == [release] (  
		set  NODE_ENV=%env% && ionic cordova build ios --device  --minifycss --minfyjs --optimizejs --prod --release --buildConfig "build.json" 
    ) else (
		set  NODE_ENV=%env% && ionic cordova build ios --device  --debug --buildConfig "build.json" 
	)
)

if /I [%1] == [android] (
	ionic cordova platform add android
	xcopy /s /y build-extras.gradle platforms/android/build-extras.gradle
	REM #TODO
	if /I [%2] == [release] (  
		set  NODE_ENV=%env% && ionic cordova build android --device --minifycss --minfyjs --optimizejs --prod --release  
    ) else ( 
		set  NODE_ENV=%env% && ionic cordova build android
	)
)
